package com.cardvalue.sys.tool;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 表达式判断
 * Created by cardvalue on 2016/4/13.
 */
public class CheckingTools {
    /**
     * 验证手机号码
     * @param str
     * @return
     */
    public static boolean isMobile(String str) {
        Pattern p = null;
        Matcher m = null;
        boolean b = false;
        p = Pattern.compile("^[1][3,4,5,8,7][0-9]{9}$");
        m = p.matcher(str);
        b = m.matches();
        return b;
    }


    /**
     * 验证密码
     * @param pwd
     * @return
     */
    public static boolean isPwd(String pwd){
        if (pwd.trim().length()<6 || pwd.trim().length()>16)
            return false;
        return true;
    }

    /**
     * 验证身份证
     * @param card
     * @return
     */
    public static boolean isAuthCard(String card){
        Pattern p = null;
        Matcher m = null;
        boolean b = false;
        p = Pattern.compile("([0-9]{17}([0-9]|X))|([0-9]{15})");
        m = p.matcher(card);
        b = m.matches();
        return b;
    }

    //Bank=;     //验证银行对私
    public static boolean BankPrivate(String bank){
        Pattern p = null;
        Matcher m = null;
        boolean b = false;
        p = Pattern.compile("\\d{10,30}");
        m = p.matcher(bank);
        b = m.matches();
        return b;
    }


    //Bank=;     //验证银行对公
    public static boolean BankPublic(String bank){
        Pattern p = null;
        Matcher m = null;
        boolean b = false;
        p = Pattern.compile("\\d{9,30}");
        m = p.matcher(bank);
        b = m.matches();
        return b;
    }

    /**
     * 验证邮箱
     * @param email
     * @return
     */
    public static boolean isEmail(String email){
        Pattern p = null;
        Matcher m = null;
        boolean b = false;
        p = Pattern.compile("^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$");
        m = p.matcher(email);
        b = m.matches();
        return b;
    }

    /**
     * 验证电话号码
     * @param phoneCode
     * @return
     */
    public static boolean isTelphone(String phoneCode){
        Pattern p = null;
        Matcher m = null;
        boolean b = false;
        p = Pattern.compile("^(0[0-9]{2,3}\\-)?([2-9][0-9]{6,7})");
        m = p.matcher(phoneCode);
        b = m.matches();
        return b;

    }

    /**
     *营业执照注册号
     * @param str
     * @return
     */
    public static boolean isbizRegisterNo(String str) {
        Pattern p = null;
        Matcher m = null;
        boolean b = false;
        p = Pattern.compile("[a-zA-Z0-9]{13,20}$");
        m = p.matcher(str);
        b = m.matches();
        return b;
    }
}
